package com.xcx.robot.mirai.factory.notaop;

import com.xcx.robot.annotation.ExceptionCatch;
import com.xcx.robot.util.ChatBot;
import net.mamoe.mirai.contact.Contact;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author: 邢晨旭
 * @Date: 2021/7/5 10:33
 * @Description:
 */
@Component
@ExceptionCatch
public class TalkFacade {

    @Resource
    ChatBot chatBot;

    public void talk(Contact sender, Contact receiver, String content) {
        if (StringUtils.isNotEmpty(content)) {
            if (!content.contains("@1687126558")) {
                return;
            }
            String result = content.replace("@1687126558", "");
            if (StringUtils.isNotEmpty(result)) {
                String talk = chatBot.talk(result);
                receiver.sendMessage(talk);
            }
        }
    }
}
